//
//  AddressBook.m
//  OC5_数组课后作业
//
//  Created by dllo on 15/10/28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AddressBook.h"

@implementation AddressBook

// 添加新联系人
- (void)tianjiaWithName:(NSString *)name sex:(NSString *)sex number:(NSInteger)number address:(NSString *)address group:(NSString *)group
{
    Contact *c1 = [[Contact alloc] initWithName:@"张三" sex:@"男" number:13888888888 address:@"南沙街12121" group:@"朋友"];
    Contact *c2 = [[Contact alloc] initWithName:@"李四" sex:@"女" number:13176452312 address:@"春柳22232" group:@"同学"];
    NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:c1, c2, nil];
    NSInteger temp = arr.count;
    [[arr objectAtIndex:temp] setName:name];
    [[arr objectAtIndex:temp] setSex:sex];
    [[arr objectAtIndex:temp] setNumber:number];
    [[arr objectAtIndex:temp] setAddress:address];
    [[arr objectAtIndex:temp] setGroup:group];
    if ([[arr objectAtIndex:arr.count] name] != nil && [[arr objectAtIndex:arr.count] number]) {
        [arr addObject:[arr objectAtIndex:arr.count]];
    } else {
        NSLog(@"添加失败");
    }
    
}




@end
